<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <!-- Copyright 2011 Google Inc.  All rights reserved. -->
  <head>
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
    <META HTTP-EQUIV="Expires" CONTENT="-1" />
    <script type="text/javascript" src="nacltest.js"></script>
    <script type="application/x-javascript">
      //<![CDATA[
      function setupTests(tester, plugin) {
        function addTest(test_name, responses) {
          if (responses === undefined) {
            responses = [];
          }
          var expected_messages = [test_name + ':PASSED'].concat(responses);
          tester.addAsyncTest('PPB_Core::' + test_name, function(test) {
            test.expectMessageSequence(plugin, expected_messages);
            plugin.postMessage(test_name)
          });
        }

        // Off the main thread.
        // Doing these tests first will check that the proxy is properly
        // caching the interface pointers on the main thread on initialization.
        addTest('TestCallOnMainThread_FromNonMainThread',
                ['CallOnMainThreadCallback_FromNonMainThread']);
        addTest('TestCallOnMainThread_FromNonMainThreadStress',
                ['CallOnMainThreadCallback_ThreadStress']);

        // On the main thread.
        addTest('TestGetTime');
        addTest('TestGetTimeTicks');
        addTest('TestIsMainThread_FromMainThread');
        addTest('TestIsMainThread_FromNonMainThread');
        addTest('TestAddRefAndReleaseResource');
        addTest('TestAddRefAndReleaseInvalidResource');
        addTest('TestCallOnMainThread_FromMainThread',
                ['CallOnMainThreadCallback_FromMainThread']);
        addTest('TestCallOnMainThread_FromMainThreadDelayed',
                ['CallOnMainThreadCallback_FromMainThreadDelayed']);

      }
      //]]>
    </script>
    <title>PPAPI PPB_Core Test</title>
  </head>
  <body>
    <h1>PPAPI PPB_Core Test</h1>

    <script type="text/javascript">
      //<![CDATA[
      function createModule(id, src, type) {
        return createNaClEmbed({
          id: id,
          src: src,
          width: 0,
          height: 0,
          type: type
        });
      }

      var mime = "application/x-nacl";
      if (getTestArguments()["pnacl"] !== undefined) {
        mime = "application/x-pnacl";
      }
      var embed = createModule("test_nexe", "ppapi_ppb_core.nmf", mime);
      document.body.appendChild(embed);

      var tester = new Tester();
      setupTests(tester, $('test_nexe'));
      tester.waitFor($('test_nexe'));
      tester.run();
      //]]>
    </script>
  </body>
</html>
